<!-- 代码已包含 CSS：使用 TailwindCSS , 安装 TailwindCSS 后方可看到布局样式效果 -->
<template>
  <div class="min-h-screen bg-gradient-to-b  text-white">
    <div class="mx-auto" style="padding: 10px;">
      <!-- 统计卡片区域 -->
      <div class="grid grid-cols-5 gap-6 mb-8">
        <div class="bg-gray-800/50 rounded-lg p-6">
          <h3 class=" text-sm mb-2">链接解析</h3>
          <div class="flex items-center justify-between">
            <div class="text-3xl font-bold">{{ pagination.total }}</div>
          </div>
        </div>
        <div class="bg-gray-800/50 rounded-lg p-6">
          <h3 class=" text-sm mb-2">音频生成</h3>
          <div class="flex items-center justify-between">
            <div class="text-3xl font-bold">{{ audio_count }}</div>
          </div>
        </div>
        <div class="bg-gray-800/50 rounded-lg p-6">
          <h3 class=" text-sm mb-2">视频生成</h3>
          <div class="flex items-center justify-between">
            <div class="text-3xl font-bold">{{ success_count }}</div>
          </div>
        </div>



      </div>
      <!-- 任务列表区域 -->
      <div class="bg-gray-800/30 rounded-lg p-6">
        <div class="flex justify-between items-center mb-6">
          <h2 class="text-xl font-bold">任务详情</h2>
        </div>
        <div class="flex flex-col gap-4">
          <div  class="bg-gray-800/50 rounded-lg p-4" style="display:flex;justify-content: space-between">
            <div>
              <div class="flex items-center justify-between">
                <div class="flex items-center gap-3">
                  <div class="w-2 h-2 rounded-full" :class="getStatusColor(task.progress)"></div>
                  <h3 class="font-medium">{{ task.title }}</h3>
                  <div class="flex gap-2">
                  </div>
                </div>
              </div>
              <div class="mt-2 ml-5">
                <div class="text-sm text-gray-400 mb-2">
                  <t-space size="24px" align="start" break-line>
                    <span>任务ID：{{ task.code }}</span>
                    <span>创建时间：{{ task.create_at }}</span>
                    <span v-if="task.zdy_video_keywords">自定义标签：{{ task.zdy_video_keywords }}</span>
                    <span>音频清晰度：{{ task.audio_platform==='蝉镜'?'标准' : '高清' }}</span>
                    <span>音频模板：{{ task.voice_name ?? "随机选择" }}</span>
                    <span v-if="task.voice_model">音频模型：{{ task.voice_model}}</span>
                    <span>视频清晰度：{{ task.video_platform==='蝉镜'?'标准' : '高清' }}</span>
                    <span>视频模板：{{ task.video_name ?? "随机选择" }}</span>
                    <template v-if="task.is_auto_fb===1">
                      <span>发布设备：{{ task.target_devices}}</span>
                      <span>发布平台：{{ task.target_platform}}</span>
                    </template>
                  </t-space>
                </div>
                <div class="flex items-center mt-2">

                <span class="text-sm px-2 py-1 rounded flex items-center"
                      :class="{
                'text-green-400 bg-green-400/10': task.progress > 1,
                'text-yellow-400 bg-yellow-400/10 border border-yellow-400': task.progress === 1 ,
                'text-gray-400 bg-gray-400/10': task.progress < 1
                }">
                链接解析
                <i v-if="task.progress > 1" class="fas fa-check text-green-400 ml-1"></i>
                </span>

                  <i class="fas fa-arrow-right text-blue-400 mx-2" :class="{ 'animate-pulse': task.progress >= 1 && task.progress < 2 }"></i>
                  <span class="text-sm px-2 py-1 rounded flex items-center"
                        :class="{
                     'text-red-400 bg-red-400/10': task.error_status === 3,
                  'text-green-400 bg-green-400/10': task.error_status !== 3 && task.progress > 3  ,
                  'text-yellow-400 bg-yellow-400/10 border border-yellow-400': task.error_status !== 3 && task.progress === 3 ,
                  'text-gray-400 bg-gray-400/10': task.error_status !== 3 && task.progress < 3
                  }">
                  AI改写
                    <i
                        v-if="task.error_status === 3"
                        class="fas fa-times text-red-400 ml-1"
                    ></i>
                <i
                    v-else-if="task.progress > 3  "
                    class="fas fa-check text-green-400 ml-1"
                ></i>
                    <!--                  <i v-if="task.progress > 3" class="fas fa-check text-green-400 ml-1"></i>-->
                  </span>


                  <i  class="fas fa-arrow-right text-blue-400 mx-2" :class="{ 'animate-pulse': task.progress >= 3 && task.progress < 4 }"></i>

                  <span class="text-sm px-2 py-1 rounded flex items-center"
                        :class="{
                    'text-red-400 bg-red-400/10': task.error_status === 4,
                  'text-green-400 bg-green-400/10': task.error_status !== 4 && task.progress > 4  ,
                  'text-yellow-400 bg-yellow-400/10 border border-yellow-400':task.error_status !== 4 &&  task.progress === 4,
                  'text-gray-400 bg-gray-400/10': task.error_status !== 4 && task.progress < 4
                  }">
                  音频生成
                     <i
                         v-if="task.error_status === 4"
                         class="fas fa-times text-red-400 ml-1"
                     ></i>
                <i
                    v-else-if="task.progress > 4  "
                    class="fas fa-check text-green-400 ml-1"
                ></i>

                  </span>

                  <i class="fas fa-arrow-right text-blue-400 mx-2" :class="{ 'animate-pulse': task.progress >= 4 && task.progress < 5 }"></i>


                  <span class="text-sm px-2 py-1 rounded flex items-center"
                        :class="{
                        'text-red-400 bg-red-400/10': task.error_status === 5,
                        'text-green-400 bg-green-400/10': task.error_status !== 5 && task.progress > 5  ,
                        'text-yellow-400 bg-yellow-400/10 border border-yellow-400': task.error_status !== 5 && task.progress === 5 ,
                        'text-gray-400 bg-gray-400/10': task.error_status !== 5 && task.progress < 5
                        }">
                        视频生成
                       <i
                           v-if="task.error_status === 5"
                           class="fas fa-times text-red-400 ml-1"
                       ></i>
                      <i
                          v-else-if="task.progress > 5  "
                          class="fas fa-check text-green-400 ml-1"
                      ></i>
                        </span>
                  <i class="fas fa-arrow-right text-blue-400 mx-2" :class="{ 'animate-pulse': task.progress >= 4 && task.progress < 5 }"></i>


                  <span v-if="task.is_auto_fb===1" class="text-sm px-2 py-1 rounded flex items-center"
                        :class="{
                        'text-red-400 bg-red-400/10': task.error_status === 6,
                        'text-green-400 bg-green-400/10': task.error_status !== 6 && task.progress > 6  ,
                        'text-yellow-400 bg-yellow-400/10 border border-yellow-400': task.error_status !== 6 && task.progress === 6 ,
                        'text-gray-400 bg-gray-400/10': task.error_status !== 6 && task.progress < 6
                        }">
                        视频发布
                       <i
                           v-if="task.error_status === 6"
                           class="fas fa-times text-red-400 ml-1"
                       ></i>
                      <i
                          v-else-if="task.progress > 6  "
                          class="fas fa-check text-green-400 ml-1"
                      ></i>
                        </span>
                  <i v-if="task.is_auto_fb===1" class="fas fa-arrow-right text-blue-400 mx-2" :class="{ 'animate-pulse': task.progress >= 5 && task.progress < 6 }"></i>



                  <!--                  <span class="text-sm px-2 py-1 rounded flex items-center"-->
                  <!--                        :class="{-->
                  <!--                        'text-green-400 bg-green-400/10': task.progress === 6,-->
                  <!--                        'text-yellow-400 bg-yellow-400/10 border border-yellow-400': task.progress >= 5 ,-->
                  <!--                        'text-gray-400 bg-gray-400/10': task.progress < 6-->
                  <!--                        }">-->
                  <span class="text-sm px-2 py-1 rounded flex items-center"
                        :class="{
                        'text-green-400 bg-green-400/10': task.progress === 7,
                        'text-gray-400 bg-gray-400/10': task.progress < 7
                        }">
                        任务完成
                        <i v-if="task.progress === 7" class="fas fa-check text-green-400 ml-1"></i>
                        </span>

                  <i v-if="task.progress!=0" :class="[
                    'fas',
                    task.error_status !== 0 ? 'fa-times-circle text-red-400' :
                    task.progress === 7 ? 'fa-check-circle text-green-400' : 'fa-spinner fa-spin text-yellow-400',
                    'ml-2'
                ]"></i>
                </div>
                <div v-if="task.error_status!==0" style="color: red;margin-top: 5px">执行失败:{{task.error_msg}}</div>
              </div>
            </div>

          </div>
        </div>

        <div class="flex justify-between items-center mb-6" style="margin-top: 20px">
          <h2 class="text-xl font-bold">任务数据</h2>
        </div>
        <div class="flex flex-col gap-4">
          <div  class="text-sm text-gray-400 mb-2" style="padding: 10px">
            <t-space size="24px" align="center">
              <!--刷新数据-->
              <t-link @click="resetData()"  theme="primary" >
                <template #prefix-icon>
                  <refresh-icon />
                </template>
                刷新
              </t-link>
              <p v-if="item.progress>5">请注意生成的视频仅保存24 小时，请及时下载。</p>
              <t-button size="medium" theme="primary" @click="batchDownloadVideo(task.id,0)" v-if="task.progress>5 && task.zip_url===null"   >批量下载</t-button>
              <t-link v-if="task.zip_url" theme="primary"  :href="task.zip_url" target="_blank">
                <template #prefix-icon>
                  <link-icon />
                </template>
                点击下载已生成完成的视频，请注意视频仅保存7天，请及时下载。
              </t-link>

              <t-button size="medium" theme="primary" v-if="task.progress>5 " @click="pushPhone()" >
                <!--                <t-button size="medium" theme="primary"  @click="textSelect(item.task_id,item.id)" >-->
                推送视频到手机
              </t-button>
            </t-space>
          </div>


          <div style="display:flex;justify-content: space-between">

            <div ref="logBox" class="bg-gray-800/50"
                 style="width: 300px; flex-shrink: 0; padding: 5px 10px; color: #4ade80; line-height: 1.8; height: 300px; overflow: hidden; position: relative">
              <div style="height: 100%; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none">
                <div style="min-height: 100%; display: flex; flex-direction: column; justify-content: flex-start">
                  <p v-for="(log, index) in logMessages" :key="index" v-html="log"></p>
                </div>
              </div>
            </div>

            <div style="flex: 1; min-width: 0;margin-left: 10px">

              <t-table
                  row-key="index"
                  :data="data"
                  :columns="columns"
                  :stripe="stripe"
                  :bordered="bordered"
                  :loading="isLoading"
                  :hover="hover"
                  :table-layout="tableLayout ? 'auto' : 'fixed'"
                  :size="size"
                  :pagination="pagination"
                  :show-header="showHeader"
                  cell-empty-content="-"
                  resizable
                  lazy-load
                  @page-change="onPageChange"
                  @select-change="onSelectChange"
                  :selected-row-keys="selectedRowKeys"
              >
                <template #ai_gaixie_content="{ row }">
                  <span v-if="row.gaixie_status === 1">暂未执行</span>
                  <span v-else-if="row.gaixie_status === 2" >{{row.ai_gaixie_content}}</span>
                  <span style="color: red" v-else>改写失败:{{row.ai_gaixie_content}}</span>
                </template>

                <template #audio_url="{ row }">
                  <span v-if="row.audio_status === 1">暂未执行</span>
                  <span v-else-if="row.audio_status === 2" style="color: #facc15">生成中</span>
                  <span v-else-if="row.audio_status === 3" @click="copyinfo(row.audio_url)" style="color: #4ade80">{{row.audio_url}}</span>
                  <span style="color: red" v-else>生成失败:{{row.audio_errmsg}}</span>
                </template>
                <template #video_url="{ row }">
                  <span v-if="row.video_status === 1">暂未执行</span>
                  <span v-else-if="row.video_status === 2" style="color: #facc15">生成中</span>
                  <span v-else-if="row.video_status === 3" @click="copyinfo(row.video_url)" style="color: #4ade80">{{row.video_url}}</span>
                  <span style="color: red" v-else>生成失败:{{row.video_errmsg}}</span>
                </template>
                <template #is_flish="{ row }">
                  <div v-if="task.is_auto_fb===1">
                    <span v-if="row.is_push === 0">暂未推送</span>
                    <span v-else style="color: #4ade80">
                      已推送<br>接收设备:{{row.device_name}}<br>
                      <span v-if="row.is_receive === 0" style="color: #4ade80">设备未接收,请检查设备是否正常</span>
                      <span v-else style="color: #4ade80">
                        设备已接收<br>
                        <span v-if="row.is_flish === 1" style="color: #4ade80">发布成功</span>
                        <span v-else>等待返回结果</span>
                      </span>
                    </span>
                  </div>
                  <div v-else>
                    <span >无需发布</span>
                  </div>


                </template>


              </t-table>


            </div>

          </div>




        </div>

      </div>
    </div>
  </div>

  <!-- 批量下载弹窗 --->
  <t-dialog
      v-model:visible="isDialogProgress"
      header="批量下载视频"
      :footer="false"
  >
    <!-- 通过 props 传递参数 -->
    <ProgressInfo v-if="isDialogProgress" :item="queue_data" />
  </t-dialog>

  <!-- 推送视频到手机弹窗 --->
  <t-dialog
      v-model:visible="isDialogPush"
      header="推送视频到手机"
      :on-confirm="subPushData"
  >
    <div v-if="isDialogPush">
      <t-space style="margin-bottom: 10px"  size="24px">
        <span>选择需要执行的操作</span>
        <!--            <t-checkbox v-model="isAutoFb"> 自动剪辑发布 </t-checkbox>-->
        <t-checkbox v-model="isAutoJjjb"> 包装剪辑 </t-checkbox>
        <t-checkbox  v-model="isAutoFbjb"> 发布 </t-checkbox>
      </t-space>
      <t-space style="margin-bottom: 10px"  size="24px" v-if="isAutoFbjb">
        <span>选择发布的平台</span>
        <t-select
            v-model="platform"
            :options="platforms"
            multiple
            placeholder="请选择"
            style="width: 300px"
        />
      </t-space>

      <t-space style="margin-bottom: 10px"   size="24px">
        <span>选择设备</span>
        <t-tree-select
            filterable
            :data="devices"
            v-model="target_device"
            multiple
            placeholder="请选择"
            :max="selectedRowKeys.length"
            style="width: 300px"
        >
        </t-tree-select>
      </t-space>
      <p>已选择{{ selectedRowKeys.length }} 个视频,请选择最多选择{{ selectedRowKeys.length }} 个 设备,系统会自动从第一个设备开始推送直至将所有视频推送完成</p>

    </div>

  </t-dialog>

</template>
<script  setup>
import {ref, onUnmounted, onMounted, nextTick} from 'vue';
import {get,post} from "@/utils/api";
import config from "@/config";
import {MessagePlugin} from "tdesign-vue-next";
import {LinkIcon, RefreshIcon} from "tdesign-icons-vue-next";
import ProgressInfo from "@/views/ProgressInfo.vue";

// eslint-disable-next-line vue/no-setup-props-destructure
const { item } = defineProps({
  item: {
    type: Object,
    required: true,
  },
});
console.log("item",item)

const logMessages = ref([
]);
const logBox = ref(null); // 添加对日志容器的引用
// 添加日志定时器
const logTimer = ref(null);
let last_log_id = 1;
let last_log_contnt = "";
let last_log_contnt1 = ""
let log_num = 0
let content = "";
onMounted(() => {
  const fetchLogs = () => {
    get(config.getRunLog, { task_id: task.value.id, id: last_log_id })
        .then(res => {
          if (res.data.data) {
            // 检查当前返回的数据是否与上一条数据相同
            //content = res.data.data.content;
            const currentContent = `[${res.data.data.create_at}]<br>${res.data.data.content}`;
            if (content ===  res.data.data.content) {
              // 数据完全相同，跳过插入操作
              log_num++;
              if (log_num > 5) {
                last_log_contnt = logMessages.value[logMessages.value.length - 1] = `${last_log_contnt1}  ·`;
                log_num = 0;
              } else {
                last_log_contnt += '  ·';
                logMessages.value[logMessages.value.length - 1] = last_log_contnt;
              }

            }else{
              content = res.data.data.content;
              last_log_contnt1 = last_log_contnt = currentContent;
              logMessages.value.push(last_log_contnt);
              last_log_id = res.data.data.id;
              log_num = 0;
            }

          } else {
            if (log_num > 5) {
              last_log_contnt = logMessages.value[logMessages.value.length - 1] = `${last_log_contnt1}  ·`;
              log_num = 0;
            } else {
              last_log_contnt += '  ·';
              logMessages.value[logMessages.value.length - 1] = last_log_contnt;
            }
            log_num++;
          }

          // 保持最多5条日志
          if (logMessages.value.length > 5) {
            logMessages.value.shift();
          }

          // 自动滚动到底部
          nextTick(() => {
            if (logBox.value) {
              logBox.value.scrollTop = logBox.value.scrollHeight;
            }
          });

          // 请求完成后再设置下一次轮询
          logTimer.value = setTimeout(fetchLogs, 1000);
        })
        .catch(error => {
          console.error('日志请求失败:', error);
          // 出错时也继续轮询
          logTimer.value = setTimeout(fetchLogs, 1000);
        });
  };

  // 启动首次请求
  logTimer.value = setTimeout(fetchLogs, 1500);
});
onUnmounted(() => {
  if (logTimer.value) {
    clearInterval(logTimer.value);
    logTimer.value = null;
    last_log_id = 1;
    last_log_contnt = "";
    last_log_contnt1 = ""
    log_num = 0
  }
});

const task = ref([

]);
const success_count = ref(0)





const getTask = async () => {

  // eslint-disable-next-line no-undef

  try {
    const response = await get(config.getTask,{task_id:item}); // Adjust API endpoint as needed
    if (response.status === 200) {
      const data = response.data;
      console.log(data)
      task.value = data.data;
      task.value = data.data;
      if(data.data.progress===7 || data.data.error_status!==0){
        clearInterval(logTimer.value);
        logTimer.value = null;
      }
    } else {
      console.error('Failed to fetch feedback data');
    }
  } catch (error) {
    console.error('Error fetching feedback data:', error);
  }
};

getTask()


const getStatusColor = (status) => {

  if(status===0){
    return 'bg-gray-400'
  }else if(status===6){
    return 'bg-green-400'
  }else {
    return 'bg-yellow-400'
  }
  // return colors[status];
};
const getTagColor = () => {
  const colors = [
    "bg-blue-500/20 text-blue-400",
    "bg-purple-500/20 text-purple-400",
    "bg-green-500/20 text-green-400",
    "bg-yellow-500/20 text-yellow-400",
    "bg-red-500/20 text-red-400",
    "bg-indigo-500/20 text-indigo-400",
    "bg-pink-500/20 text-pink-400",
    "bg-orange-500/20 text-orange-400"

  ];
  //随机取颜色
  return colors[0];
};

const  aigaixu_count = ref(0)
const  audio_count = ref(0)

//统计任务数据
const getDataCount =  () => {
  get(config.getDataCount,{task_id:item}).then(res=>{
    console.log("getDataCount", res.data.data)
    let data = res.data.data
    aigaixu_count.value = data.aigaixu_count
    audio_count.value = data.audio_count
    success_count.value = data.success_count
  })
}
getDataCount()


//表格部分
const data = ref([])
const total = 28;


const stripe = ref(true);
const bordered = ref(true);
const hover = ref(false);
const tableLayout = ref(false);
const size = ref('medium');
const showHeader = ref(true);
const isLoading = ref(false);
const selectedRowKeys = ref([]);
const pagination = ref({
  defaultCurrent: 1,
  defaultPageSize: 10,
  total,
});

const columns = ref([
  {
    colKey: 'row-select',
    type: 'multiple',
    width: 50,
  },
  { colKey: 'serial-number', title: '序号', width: 80 },
  { colKey: 'title', title: '标题', ellipsis: {
      theme: 'light',
      placement: 'bottom'
    }},
  { colKey: 'content', title: '文案', ellipsis: {
      theme: 'light',
      placement: 'bottom'
    }},
  { colKey: 'video_title', title: '视频标题' , ellipsis: {
      theme: 'light',
      placement: 'bottom'
    }},
  { colKey: 'video_keywords', title: '视频话题', ellipsis: {
      theme: 'light',
      placement: 'bottom'
    }},
  { colKey: 'video_content', title: '视频内容', ellipsis: {
      theme: 'light',
      placement: 'bottom'
    } },
  { colKey: 'ai_gaixie_content', title: 'AI文案',
    ellipsis: {
      theme: 'light',
      placement: 'bottom',
    } },
  { colKey: 'emotion', title: '语音情绪' },
  { colKey: 'audio_url', title: '音频URL' , ellipsis: {
      theme: 'light',
      placement: 'bottom'
    }},
  { colKey: 'video_url', title: '视频URL', ellipsis: {
      theme: 'light',
      placement: 'bottom'
    }},
  { colKey: 'is_flish', title: '发布状态', ellipsis: {
      theme: 'light',
      placement: 'bottom'
    }},
]);


const getTaskData = async (paginationInfo) => {
  try {
    const { current, pageSize } = paginationInfo;
    console.log("pageSize",pageSize)
    const response = await get(config.getTaskData,{
      task_id:item,
      page:current,
      page_size:pageSize
    }); // Adjust API endpoint as needed
    if (response.status === 200) {
    //  const data = response.data;
      console.log("getTaskData",response.data.data)
      let list  = response.data.data.list
      list.forEach(item=>{
        item.index=item.id
      })
      console.log("list",list)
      data.value = list;
      pagination.value.total = response.data.data.page.total;
    } else {
      console.error('Failed to fetch feedback data');
    }
  } catch (error) {
    console.error('Error fetching feedback data:', error);
  }
};

getTaskData({
  current: pagination.value.current || pagination.value.defaultCurrent,
  pageSize: pagination.value.pageSize || pagination.value.defaultPageSize,
})

const rehandleChange = (changeParams, triggerAndData) => {
  console.log('分页、排序、过滤等发生变化时会触发 change 事件：', changeParams, triggerAndData);
};

// BaseTable 中只有 page-change 事件，没有 change 事件
const onPageChange = async (pageInfo) => {
  console.log('page-change', pageInfo);
  await getTaskData(pageInfo);
};

const onSelectChange = (value, params) => {
  selectedRowKeys.value = value;
  console.log(value, params);
};

const timer_detail = ref(null)
timer_detail.value =setInterval(() => {
  getDataCount()
  getTaskData({
    current: pagination.value.current || pagination.value.defaultCurrent,
    pageSize: pagination.value.pageSize || pagination.value.defaultPageSize,
  })
  getTask()
}, 10000);
onUnmounted(() => {
  if (timer_detail.value) {
    clearInterval(timer_detail.value)
    timer_detail.value = null
  }
})
const resetData = () =>{
  let loading = MessagePlugin.loading("数据加载中...")
  getTaskData({
    current: pagination.value.current || pagination.value.defaultCurrent,
    pageSize: pagination.value.pageSize || pagination.value.defaultPageSize,
  })
  //延时执行
  setTimeout(() => {
    MessagePlugin.close(loading)
  }, 1000);

}
const isDialogProgress = ref(false)
const queue_data = ref([])
//批量下载视频
const batchDownloadVideo =  (task_id,task_run_log_id) => {
  get(config.batchDownloadVideo,{
    task_id:task_id,
    task_run_log_id:task_run_log_id
  }).then(res=>{
    console.log("batchDownloadVideo", res.data.data)
    if(res.data.code===1){
      queue_data.value.code = res.data.data;
      queue_data.value.task_id = task_id;
      queue_data.value.task_run_log_id = task_run_log_id;
      isDialogProgress.value=true
      MessagePlugin.success('操作成功')
    }else{
      MessagePlugin.error(res.data.info)
    }
  })
}
//推送视频到手机
const isDialogPush = ref(false)
const isAutoJjjb = ref(false)
const isAutoFbjb = ref(false)
const target_device = ref([])
const pushPhone =  () => {
  if(selectedRowKeys.value.length===0){
    MessagePlugin.error('请选择需要推送的视频')
  }else{

    deviceList()

  }
}


const devices = ref();
const deviceList = async () => {
  console.log("deviceList");
  try {
    const response = await get(config.getDeviceListGroup,{
      status:1
    }); // Adjust API endpoint as needed
    if (response.status === 200) {
      if(response.data.code===0){
        MessagePlugin.error(response.data.info)
      }else{
        isDialogPush.value = true
        devices.value  = response.data.data;
      }

      console.log("deviceList",devices.value)
      // data.value = data;
    } else {
      console.error('Failed to fetch feedback data');
    }
  } catch (error) {
    console.error('Error fetching feedback data:', error);
  }


};
const subPushData = ()=>{
  if(target_device.value.length===0){
    MessagePlugin.error('请选择推送设备');
    return false;
  }
  if(!isAutoJjjb.value && !isAutoFbjb.value){
    MessagePlugin.error('请至少选择一种操作');
    return false;
  }
  if(isAutoFbjb.value){
    if(platform.value.length===0 ){
      MessagePlugin.error('请选择发布平台');
    }
  }
  post(config.manualPushVideo,{
    ids:selectedRowKeys.value,
    device_ids:target_device.value,
    is_auto_jjjb:isAutoJjjb.value ? 1: 2,
    is_auto_fbjb:isAutoFbjb.value ? 1: 2,
    platform:platform.value
  }).then(res=>{
    console.log("manualPushVideo", res.data.data)
    if(res.data.code===1){
      isDialogPush.value = false
      selectedRowKeys.value = []
      target_device.value = []
      isAutoFbjb.value =  false
      isAutoJjjb.value =  false
      platform.value = [1]
      MessagePlugin.success('操作成功')
    }else{
      MessagePlugin.error(res.data.info)
    }
  })
}
const platform = ref([1])
const platforms = ref([
  {
    label: '抖音',
    value: 1,
  },
  {
    label:'小红书',
    value: 2
  },
  {
    label: '微信视频号',
    value: 3,
  }

])
</script>
<style scoped>
/* 移除所有CSS样式，改用TailwindCSS类 */
.bg-gray-800\/50{
  background-color: rgb(50 53 56 / 50%);
}
.bg-gray-800\/30{
  background-color: rgb(39 43 48 / 30%)
}
</style>
